<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">


<div class="">
    <div class="page-title">
        <div class="title_left">
            <h3>设置</h3>
        </div>

       
    </div>
    <div class="clearfix"></div>

    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h2>外观
                        
                    </h2>
                    <ul class="nav navbar-right panel_toolbox">
                      
                        <li><a  title="折叠" class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                        
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                   <form class="form-horizontal">
                   <div class="form-group form-group-sm">
                   <label class="col-sm-3 control-label">主题：</label>
                   <div class="col-sm-5">
                   <select class="form-control" id="themeItem">
                  
                   </select>
                   </div>
                   </div>
                   </form>
                </div>
            </div>
             <!-- <div class="x_panel">
                <div class="x_title">
                    <h2>左边栏菜单排序
                        
                    </h2>
                    <ul class="nav navbar-right panel_toolbox">
                      
                        <li><a  title="折叠" class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                        
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                <div class="col-sm-12">
                <a title="上移"><i class="fa fa-hand-up"></i></a>
                </div>
                   <form class="form-horizontal">
                   <div class="form-group form-group-sm">
                   <label class="col-sm-3 control-label">主题：</label>
                   <div class="col-sm-5">
                   <select class="form-control">
                   <option value="0">深色</option>
                   </select>
                   </div>
                   </div>
                   </form>
                </div>
            </div> -->
            <div class="col-sm-12">
            <div class="col-sm-6 text-right"> <button type="button" th:onclick="'javascript:saveEditSettings()'">保存</button></div>
             <div class="col-sm-4 text-left"> <button type="button" th:onclick="'javascript:cacelEditSetings()'">取消</button></div>
           
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
		var settings={id:0,settingName:"主题"}
		$("#themeItem").change(function(){
			settings.value = $(this).val(); 
			
		})
		getThemeList();
		
		function getThemeList(){
			$.ajax({
                type: "GET",
                url: "/setting/GetThemeList",//url请求的地址
                cache: false,  //禁用缓存
                 //传入组装的参数
                dataType: "json",
                success: function (result) {
                	console.log(123)
                	appendTheme(result)
                }
            });
		}
		function saveEditSettings(){
			
			settings.value = $("#themeItem").val();
			$.ajax({
                type: "POST",
                url: "/setting/SaveSettings",//url请求的地址
                cache: false,  //禁用缓存
                data: settings,  //传入组装的参数
                dataType: "html",
                success: function (result) {
                	window.location.reload(); 
					
					
                }
            });
			
		}
		function appendTheme(list){
			for(var i=0;i<list.length;i++){
				var ele=$("<option></option>");
				ele.attr("value",list[i].theme_name).text(list[i].theme_name)
				$("#themeItem").append(ele);
				$("#themeItem").val(window.theme["theme_name"])
				
			}
		}
		function cacelEditSetings(){
			$("#themeItem").val(window.theme["theme_name"])
		}
	
		
	
	


</script>

</html>